package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoCollectFootprint;
import com.muyu.danmo.service.IDanmoCollectFootprintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 拾贝信息足迹Controller
 * 
 * @author yangle
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/collectFootprint")
public class DanmoCollectFootprintController extends BaseController
{
    @Autowired
    private IDanmoCollectFootprintService danmoCollectFootprintService;

    /**
     * 查询拾贝信息足迹列表
     */
//    @RequiresPermissions("system:collectFootprint:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoCollectFootprint>> list(DanmoCollectFootprint danmoCollectFootprint)
    {
        startPage();
        List<DanmoCollectFootprint> list = danmoCollectFootprintService.selectDanmoCollectFootprintList(danmoCollectFootprint);
        return getDataTable(list);
    }

    /**
     * 导出拾贝信息足迹列表
     */
//    @RequiresPermissions("system:collectFootprint:export")
    @Log(title = "拾贝信息足迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoCollectFootprint danmoCollectFootprint)
    {
        List<DanmoCollectFootprint> list = danmoCollectFootprintService.selectDanmoCollectFootprintList(danmoCollectFootprint);
        ExcelUtil<DanmoCollectFootprint> util = new ExcelUtil<DanmoCollectFootprint>(DanmoCollectFootprint.class);
        util.exportExcel(response, list, "拾贝信息足迹数据");
    }

    /**
     * 获取拾贝信息足迹详细信息
     */
//    @RequiresPermissions("system:collectFootprint:query")
    @GetMapping(value = "/{id}")
    public  Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoCollectFootprintService.selectDanmoCollectFootprintById(id));
    }

    /**
     * 新增拾贝信息足迹
     */
//    @RequiresPermissions("system:collectFootprint:add")
    @Log(title = "拾贝信息足迹", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoCollectFootprint danmoCollectFootprint)
    {
        return toAjax(danmoCollectFootprintService.insertDanmoCollectFootprint(danmoCollectFootprint));
    }

    /**
     * 修改拾贝信息足迹
     */
//    @RequiresPermissions("system:collectFootprint:edit")
    @Log(title = "拾贝信息足迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoCollectFootprint danmoCollectFootprint)
    {
        return toAjax(danmoCollectFootprintService.updateDanmoCollectFootprint(danmoCollectFootprint));
    }

    /**
     * 删除拾贝信息足迹
     */
//    @RequiresPermissions("system:collectFootprint:remove")
    @Log(title = "拾贝信息足迹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoCollectFootprintService.deleteDanmoCollectFootprintByIds(ids));
    }
}
